<?php
/**
 * 会员照片
 * @author chguoxi, <chguoxi@gmail.com>
 */
class PhotoAction extends AdministratorAction {
	public function _initialize(){
		$this->modelName = 'Image';
		parent::_initialize();
	}
	
	public function edit(){
		if ( $this->isPost() ){
			$uploadInfo = upload();
			if ( $uploadInfo['error'] == 0 ){
				$data = array(
					'uid'=>$this->_request('uid')
				);
				try {
					$this->modelObj->add($data);
				} catch (ThinkException $e) {
					$this->error($e->getMessage());
				}
			}
			else{
				$this->error($uploadInfo['message']);
			}
		}
		else{
			$this->display('Photo:edit');
		}
	}
}